package org.computate.form.item;

import java.util.List;

import org.computate.form.ComputateForm;
import org.computate.model.item.Model;
import org.computate.tool.FormTool;



public class FormField extends FormItem {
	
	private String name;
	private String description;
	private Boolean required;
	private List<? extends Model> items = null;
	private boolean textarea;
	private String itemName;
	private String itemDisplayName;
	private String itemPluralName;
	private ComputateForm form;
	private boolean dropdown;
	private Integer stars = null;
	private String width = null;
	private String noneLabel = "None";
	
	public String getName() {
		return name;
	}
	
	public FormField setName(String name) {
		this.name = name;
		
		return this;
	}
	
	public String getDescription() {
		return description;
	}
	
	public FormField setDescription(String description) {
		this.description = description;
		
		return this;
	}

	public Boolean getRequired() {
		return required;
	}

	public FormField setRequired(Boolean required) {
		this.required = required;
		
		return this;
	}

	public Object getValue(ComputateForm computateForm) {
		return FormTool.getValue(computateForm, name);
	}
	
	
	public String getValueString(ComputateForm computateForm) {
		return FormTool.getValueString(computateForm, name);
	}

	public List<? extends Model> getItems() {
		return items;
	}

	public FormField setItems(List<? extends Model> items) {
		this.items = items;
		
		return this;
	}

	public boolean isTextarea() {
		return textarea;
	}

	public FormField setTextarea(boolean textarea) {
		this.textarea = textarea;
		
		return this;
	}

	public String getItemName() {
		return itemName;
	}

	public FormField setItemName(String itemName) {
		this.itemName = itemName;
		
		return this;
	}

	public String getItemDisplayName() {
		return itemDisplayName;
	}

	public FormField setItemDisplayName(String itemDisplayName) {
		this.itemDisplayName = itemDisplayName;
		
		return this;
	}

	public String getItemPluralName() {
		return itemPluralName;
	}

	public FormField setItemPluralName(String itemPluralName) {
		this.itemPluralName = itemPluralName;
		
		return this;
	}

	public ComputateForm getForm() {
		return form;
	}

	public void setForm(ComputateForm form) {
		this.form = form;
	}

	public boolean isDropdown() {
		return dropdown;
	}

	public FormField setDropdown(boolean dropdown) {
		this.dropdown = dropdown;
		
		return this;
	}

	public Integer getStars() {
		return stars;
	}

	public FormField setStars(Integer stars) {
		this.stars = stars;
		
		return this;
	}

	public String getWidth() {
		return width;
	}

	public FormField setWidth(String width) {
		this.width = width;
		
		return this;
	}

	public String getNoneLabel() {
		return noneLabel;
	}

	public FormField setNoneLabel(String noneLabel) {
		this.noneLabel = noneLabel;
		
		return this;
	}
}
